package cn.ryh.designpatterndemo.proxypattern.staticproxy;


/**
 * @ClassName StaticSubjectImplProxy
 * @Description TODO
 * @Author RaoYH
 * @Date 2019/4/23
 */
public class StaticSubjectImplProxy implements StaticSubject {
    // 要代理哪个实现类
    private  StaticSubject staticSubject = null;
    // 默认被代理者
    public StaticSubjectImplProxy (){
        this.staticSubject = new StaticSubjectImplProxy();
    }
    // 通过有参构造函数传递要对谁进行代理
    public StaticSubjectImplProxy (StaticSubject staticSubjects){
        this.staticSubject = staticSubjects;
    }
    @Override
    public void doSomething() {
        //
        this.before();
        this.staticSubject.doSomething();
        this.after();
    }

    // 前置处理
    private void before(){
        System.out.println("--->前置处理：do something");

    }
    // 后置处理
    private void after(){
        System.out.println("--->后置处理：do something");
    }
}
